package asimes.datastructure.queue;

import java.util.PriorityQueue;
import java.util.Queue;

public class TestQueue1 {
    public static void main(String[] args) {
        Queue<Customer> customerQueue = new PriorityQueue<>();
        customerQueue.add(new Customer(15, "A"));
        customerQueue.add(new Customer(12, "B"));
        customerQueue.add(new Customer(13, "C"));
        customerQueue.add(new Customer(14, "D"));
        customerQueue.add(new Customer(17, "E"));
        System.out.println(customerQueue.size());
        while (!customerQueue.isEmpty()) {
            System.out.println(customerQueue.poll());
        }
    }


}

class Customer implements Comparable<Customer> {
    private int age;
    private String name;

    public Customer(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Customer o) {
        return age - o.age;
    }
}
